package configs;

import com.fasterxml.jackson.core.type.TypeReference;
import kotlin.text.StringsKt;
import tools.JsonUtil;
import tools.config.Property;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;


public class CubeConfig {
    public static ArrayList filter_list;
    public static HashMap chance_data;

    public static final CubeConfig INSTANCE;
    @Property(key = "filter.list", defaultValue = "")
    public static String FILTER_LIST;
    @Property(key = "chance.data", defaultValue = "")
    public static String CHANCE_DATA;
    public final int getChance(int itemid, int rank) {
        int newItemID = chance_data.containsKey(itemid) ? itemid : 0;
        HashMap var10000 = (HashMap)chance_data.get(newItemID);
        if (var10000 == null) {
            var10000 = new HashMap();
        }

        HashMap chancelist = var10000;
        Integer var5 = (Integer)chancelist.get(rank);
        if (var5 == null) {
            var5 = 0;
        }

        return var5 * 10;
    }
    public final boolean isFilter(int id) {
        return filter_list.contains(id);
    }


    public final void updateFilterList() {
        Iterator iterator;
        filter_list.clear();
        CharSequence charSequence = FILTER_LIST;
        if ((charSequence.length() > 0)) {
            Iterable $receiver$iv = StringsKt.split(StringsKt.replace(FILTER_LIST, " ","",false),new String[]{","},false,6);
            iterator = $receiver$iv.iterator();
        } else {
            return;
        }
        if (iterator.hasNext()) {
            Object element$iv = iterator.next();
            String it = (String)element$iv;
            String str1 = it;
            ArrayList<Integer> arrayList = filter_list;
            int i = Integer.parseInt(str1);
            arrayList.add(Integer.valueOf(i));
        }
    }
////
    public final void updateChanceData() {
        chance_data.clear();
        CharSequence var1 =  CHANCE_DATA;
        if (var1.length() > 0) {
            try {
                chance_data.putAll(JsonUtil.getMapperInstance().readValue(CHANCE_DATA, new TypeReference<Map<String, Object>>() {}));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
//
//    private CubeConfig() {
//    }
//
    static {
        CubeConfig var0 = new CubeConfig();
        INSTANCE = var0;
        FILTER_LIST = "";
        CHANCE_DATA = "";
        filter_list = new ArrayList();
        chance_data = new HashMap();
    }


}
